package top.purity.server.user.feign.output;

import top.purity.framework.common.GlobalConstant;
import top.purity.framework.common.exception.ServiceException;
import top.purity.server.user.feign.output.dto.AddUserDTO;
import top.purity.server.user.feign.output.dto.LoginDTO;
import top.purity.server.user.feign.output.dto.PermissionDTO;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

public interface UserFeign {

    String PREFIX = GlobalConstant.RPC_PREFIX + "/user";

    /**
     * 登陆时根据账号和租户编号获取用户的基本信息
     * @param username 账号
     * @param tenantCode 租户编号
     * @return 基本信息
     */
    @PostMapping(PREFIX + "/getByUsernameAndTenantCode/{username}/{tenantCode}")
    LoginDTO getByUsername(@PathVariable("username") String username, @PathVariable("tenantCode") String tenantCode) throws ServiceException;

    @PostMapping(PREFIX + "/getPermission/{userId}/{tenantId}")
    List<PermissionDTO> getPermission(@PathVariable("userId") Long userId, @PathVariable("tenantId") Long tenantId);

    @PostMapping(PREFIX + "/isRootAdmin/{userId}/{tenantId}")
    Boolean isRootAdmin(@PathVariable("userId") Long userId, @PathVariable("tenantId") Long tenantId) throws ServiceException;

    @PostMapping(PREFIX + "/addUserByAddTenant")
    void addUserByAddTenant(@RequestBody AddUserDTO dto);
}
